package com.gongzhiyun.springboot3test.mapper.novel;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gongzhiyun.springboot3test.entity.novel.NovelReading;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface NovelReadingMapper extends BaseMapper<NovelReading> {

    //检验要保存的记录存不存在
    @Select("select  * from novel_reading where novel_id=#{novelId} and user_id=#{userId}")
    NovelReading queryReading(Integer novelId,Integer userId);

    //获取某用户对某小说的阅读章节记录
    @Select("select chapter_id from novel_reading where novel_id=#{novelId} and user_id=#{userId} ")
    Integer getReading(Integer novelId,Integer userId);

    @Select("select * from novel_reading where user_id=#{userId}")
    List<NovelReading> getUserReading(Integer userId);

}
